#include "editormodemanager.h"
#include "objecteditormode.h"
#include "leveleditormode.h"
#include "document.h"

using namespace Modes;

EditorModeManager::EditorModeManager(MainWindow& mainWindow, QObject *parent)
	: StateManager(parent)
	, m_mainWindow(mainWindow)
{
	registerState(new ObjectEditorMode(*this));
	registerState(new LevelEditorMode(*this));
}

MainWindow& Modes::EditorModeManager::mainWindow()
{
	return m_mainWindow;
}

void Modes::EditorModeManager::onDocumentChanged( QPointer<Document> doc )
{
	const States& listOfStates = states();

	foreach(QPointer<AbstractState> state, listOfStates)
	{
		QPointer<EditorMode> em = qobject_cast<EditorMode*>(state);
		Q_ASSERT(em);
		em->onDocumentChanged(doc);
	}
}
